package org.example.springbook.enums;

public enum BookStatusEnum {
     DELETE(0, "删除"),
     NORMAL(1, "可借阅"),
     FORBIDDEN(2, "不可借阅");
     private int code;

     private String name;

     // 为什么定义成static 不定义成static 也可以 但是要new 枚举对象才可以使用这个方法
     // 这样的话 定义成static才更为合适
     public static BookStatusEnum getNameByCode(int code) {
          switch (code) {
               case 0: return BookStatusEnum.DELETE;
               case 1: return BookStatusEnum.NORMAL;
               default:
                    return BookStatusEnum.FORBIDDEN;
          }
     }

     BookStatusEnum(int code, String name) {
          this.code = code;
          this.name = name;
     }

     public int getCode() {
          return code;
     }

     public void setCode(int code) {
          this.code = code;
     }

     public String getName() {
          return name;
     }

     public void setName(String name) {
          this.name = name;
     }
}